home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / m2gem106.lzh / CRYSTAL1.06 / TST / VDITEST / VDITEST.M2 next >
Encoding:
Text File  |  1993-11-14  |  8.6 KB  |  321 lines

  1. (***************************************************************************)
  2. (* VDI Test Programm.                                                      *)
  3. (* Zeichnet ein Haus und einen Text auf ein beliebiges Ausgabegerät.       *)
  4. (* Entnommen aus:                                                          *)
  5. (* Geiß, Geiß: "Vom Anfänger zum GEM-Profi", Sybex-Verlag                  *)
  6. (* 14/11/1993                                                              *)
  7. (***************************************************************************)
  8.  
  9. MODULE VDITest;
  10.  
  11. FROM ApplMgr    IMPORT ApplInit,ApplExit;
  12. FROM EvntMgr    IMPORT EvntKeybd;
  13. FROM FormMgr    IMPORT FormAlert;
  14. FROM GrafMgr    IMPORT GrafHandle,GrafMouse,MOn,MOff;
  15. FROM VControl   IMPORT Screen,Plotter,Printer,Camera,Metafile,Memory,Image,
  16.                        OWNoChange,RC,NDC,MaxWorkIn,MaxWorkOut,
  17.                        VOpnVWk,VOpnWk,VSTLoadFonts,VSTUnloadFonts,
  18.                        VClsVWk,VClsWk,VUpdWk,VClrWk,VSClip;
  19. FROM VAttribute IMPORT MdTrans,VSWrMode,VSLColor,LTSolid,VSLType,
  20.                        VSTColor,VSTFont,VSTEffects,Normal,
  21.                        VSTAlignment,HorizontalAlignments,VerticalAlignments,
  22.                        VSTPoint,VSTRotation;
  23. FROM VOutput    IMPORT VPLine,VGText;
  24. FROM VInput     IMPORT VHideC,VShowC,VRqString;
  25. FROM VScreen    IMPORT VEnterCur,VCurHome,VExitCur,VCurText;
  26. FROM VMetafile  IMPORT VMFileName,VMetaExtents,VMPageSize,VMCoords;
  27. FROM PORTAB     IMPORT UNSIGNEDWORD,NULL,ANYPOINTER;
  28. FROM INTRINSIC  IMPORT VOID,PTR;
  29.  
  30. IMPORT AES,VDI;
  31.  
  32. VAR WorkIn      : ARRAY[0..(MaxWorkIn - 1)] OF UNSIGNEDWORD;
  33.     WorkOut     : ARRAY[0..(MaxWorkOut - 1)] OF UNSIGNEDWORD;
  34.     VDIHandle   : UNSIGNEDWORD;
  35.     ScreenHandle: UNSIGNEDWORD;
  36.     FromDesktop : BOOLEAN;
  37.     MetaName    : ARRAY[0..79] OF CHAR;
  38.     MinX        : VDI.XY;
  39.     MinY        : VDI.XY;
  40.     MaxX        : VDI.XY;
  41.     MaxY        : VDI.XY;
  42.     ScreenW     : VDI.XY;
  43.     ScreenH     : VDI.XY;
  44.     MetaW       : VDI.XY;
  45.     MetaH       : VDI.XY;
  46.  
  47. (***************************************************************************)
  48.  
  49. PROCEDURE Wait;
  50.  
  51. VAR EchoXY: ARRAY[0..1] OF VDI.XY;
  52.     String: ARRAY[0..1] OF CHAR;
  53.  
  54. BEGIN
  55.   EchoXY[0]:= 0;
  56.   EchoXY[1]:= 0;
  57.  
  58.   IF FromDesktop THEN
  59.     VOID(EvntKeybd());
  60.   ELSE
  61.     VRqString(ScreenHandle,1,FALSE,EchoXY,String);
  62.   END;
  63. END Wait;
  64.  
  65. (***************************************************************************)
  66.  
  67. PROCEDURE OpenWork(Device: UNSIGNEDWORD; Coord: UNSIGNEDWORD): BOOLEAN;
  68.  
  69. CONST MaxMemory = 32767; (* 512 kB (32768 * 16) *)
  70.       FreeSpace = 4096;  (*  64 kB ( 4096 * 16) *)
  71.  
  72. VAR i     : UNSIGNEDWORD;
  73.     Fonts : UNSIGNEDWORD;
  74.     Clip  : ARRAY[0..3] OF VDI.XY;
  75.     Buffer: VDI.MFDB;
  76.  
  77. BEGIN
  78.   IF ApplInit() < 0 THEN
  79.     FromDesktop:= AES.Version() > 0; (* Aufruf vom Desktop aus? *)
  80.     IF FromDesktop THEN
  81.       RETURN FALSE; (* Aufruf vom Desktop nicht erfolgreich *)
  82.     END;
  83.   ELSE
  84.     FromDesktop:= TRUE; (* ApplInit() erfolgreich *)
  85.   END;
  86.  
  87.   FOR i:= 0 TO (MaxWorkIn - 1) DO
  88.     WorkIn[i]:= 1;
  89.   END;
  90.  
  91.   WorkIn[0]:= Device; (* device handle *)
  92.   WorkIn[10]:= Coord; (* NDC/RC Koordinaten *)
  93.  
  94.   IF Device # Screen THEN    (* GEM/3 Erweiterungen *)
  95.     WorkIn[11]:= OWNoChange; (* Paralleler oder serieller Port *)
  96.     WorkIn[12]:= 0;          (* Port #0 *)
  97.   END;
  98.  
  99.   IF Device = Screen THEN
  100.     IF FromDesktop THEN
  101.       VDIHandle:= GrafHandle(i,i,i,i);
  102.       VOpnVWk(WorkIn,VDIHandle,WorkOut); (* virtuell öffnen *)
  103.       GrafMouse(MOff,NULL);
  104.     ELSE
  105.       VOpnWk(WorkIn,0,0,VDIHandle,WorkOut,Buffer); (* physikalisch öffnen *)
  106.       IF VDIHandle > 0 THEN
  107.         VHideC(VDIHandle);
  108.       END;
  109.     END;
  110.  
  111.     IF Coord = RC THEN
  112.       ScreenHandle:= VDIHandle;          (* merken *)
  113.  
  114.       ScreenW:= WorkOut[0];
  115.       ScreenH:= WorkOut[1];
  116.     END;
  117.   ELSE
  118.     Buffer.FDAddr:= NULL;
  119.     Buffer.FDNPlanes:= 0;
  120.     VOpnWk(WorkIn,1279,959,VDIHandle,WorkOut,Buffer); (* nicht Bildschirm *)
  121.   END;
  122.  
  123.   IF VDIHandle > 0 THEN
  124.     CASE Device OF
  125.       Screen:
  126.         IF Coord = RC THEN            (* Vorsichtsmaßnahme *)
  127.           Clip[0]:= 0;
  128.           Clip[1]:= 0;
  129.           Clip[2]:= ScreenW;
  130.           Clip[3]:= ScreenH;
  131.           VSClip(ScreenHandle,TRUE,Clip);
  132.         END;
  133.         VClrWk(VDIHandle);            (* Bildschirm löschen *)
  134.     | Plotter,Printer,Camera:
  135.         ;
  136.     | Metafile:
  137.         VMFileName(VDIHandle,MetaName);
  138.     ELSE
  139.       ;
  140.     END;
  141.  
  142.     Fonts:= VSTLoadFonts(VDIHandle,0,MaxMemory,FreeSpace);
  143.   END;
  144.   RETURN VDIHandle > 0;
  145. END OpenWork;
  146.  
  147. (***************************************************************************)
  148.  
  149. PROCEDURE CloseWork(Device: UNSIGNEDWORD; Coord: UNSIGNEDWORD);
  150.  
  151. VAR llx   : VDI.XY;
  152.     lly   : VDI.XY;
  153.     urx   : VDI.XY;
  154.     ury   : VDI.XY;
  155.     Buffer: VDI.MFDB;
  156.  
  157. BEGIN
  158.   IF Device = Screen THEN
  159.     Wait;
  160.   END;
  161.  
  162.   IF FromDesktop AND (Device = Screen) THEN
  163.     GrafMouse(MOn,NULL);
  164.     VSTUnloadFonts(VDIHandle,0);
  165.     VClsVWk(VDIHandle);
  166.     ApplExit;
  167.   ELSE
  168.     CASE Device OF
  169.       Screen:
  170.         VShowC(VDIHandle,TRUE);
  171.     | Metafile:
  172.         IF Coord = NDC THEN
  173.           llx:= 0;
  174.           lly:= 0;
  175.           urx:= MetaW;
  176.           ury:= MetaH;
  177.         ELSE           (* RC *)
  178.           llx:= 0;
  179.           lly:= MetaH;
  180.           urx:= MetaW;
  181.           ury:= 0;
  182.         END;
  183.         VMetaExtents(VDIHandle,MinX,MinY,MaxX,MaxY);
  184.         VMPageSize(VDIHandle,1905,2540); (* letter size = 7,5 x 10.00 Zoll *)
  185.         VMCoords(VDIHandle,llx,lly,urx,ury);
  186.     ELSE
  187.       Buffer.FDAddr:= NULL;
  188.       VOID(VUpdWk(VDIHandle,Buffer));
  189.     END;
  190.     VSTUnloadFonts(VDIHandle,0);
  191.     VClsWk(VDIHandle);
  192.   END;
  193. END CloseWork;
  194.  
  195. (***************************************************************************)
  196.  
  197. PROCEDURE House(Device: UNSIGNEDWORD; Coord: UNSIGNEDWORD);
  198.  
  199. CONST Swiss = 2;
  200.  
  201. VAR i    : UNSIGNEDWORD;
  202.     pxy  : ARRAY[0..11] OF VDI.XY;
  203.     Text : ARRAY[0..15] OF CHAR;
  204.     HorAl: HorizontalAlignments;
  205.     VerAl: VerticalAlignments;
  206.     ErrorMessage: AES.String;
  207.  
  208. BEGIN
  209.   IF OpenWork(Device,Coord) THEN
  210.     IF Coord = NDC THEN
  211.       pxy[0]:= 6000;
  212.       pxy[1]:= 6000;
  213.       pxy[2]:= 6000;
  214.       pxy[3]:= 10000;
  215.       pxy[4]:= 10000;
  216.       pxy[5]:= 12000;
  217.       pxy[6]:= 14000;
  218.       pxy[7]:= 10000;
  219.       pxy[8]:= 14000;
  220.       pxy[9]:= 6000;
  221.       pxy[10]:= 6000;
  222.       pxy[11]:= 6000;
  223.  
  224.       IF Device = Metafile THEN
  225.         MinX:= pxy[0];
  226.         MinY:= pxy[1];
  227.         MaxX:= pxy[6];
  228.         MaxY:= pxy[5];
  229.  
  230.         MetaW:= 32766;
  231.         MetaH:= 32766;
  232.       END;
  233.     ELSE (* RC *)
  234.       pxy[0]:= 100;
  235.       pxy[1]:= 200;
  236.       pxy[2]:= 100;
  237.       pxy[3]:= 100;
  238.       pxy[4]:= 200;
  239.       pxy[5]:= 50;
  240.       pxy[6]:= 300;
  241.       pxy[7]:= 100;
  242.       pxy[8]:= 300;
  243.       pxy[9]:= 200;
  244.       pxy[10]:= 100;
  245.       pxy[11]:= 200;
  246.  
  247.       IF Device = Metafile THEN
  248.         MinX:= pxy[0];
  249.         MinY:= pxy[5];
  250.         MaxX:= pxy[6];
  251.         MaxY:= pxy[1];
  252.  
  253.         MetaW:= ScreenW;
  254.         MetaH:= ScreenH;
  255.       END;
  256.     END;
  257.  
  258.     VSWrMode(VDIHandle,MdTrans);
  259.     VSLColor(VDIHandle,VDI.Red);
  260.     VSLType(VDIHandle,LTSolid);
  261.     VPLine(VDIHandle,6,pxy); (* Haus zeichnen *)
  262.  
  263.     VSTColor(VDIHandle,VDI.Green);
  264.     VSTFont(VDIHandle,Swiss);
  265.     VSTEffects(VDIHandle,Normal);
  266.     VSTAlignment(VDIHandle,TALeft,TABottom,HorAl,VerAl);
  267.     VOID(VSTPoint(VDIHandle,10,i,i,i,i));
  268.     VSTRotation(VDIHandle,0);
  269.     Text:= "VDI-Test HAUS";
  270.     VGText(VDIHandle,pxy[0],pxy[1],Text);
  271.     CloseWork(Device,Coord);
  272.   ELSE
  273.     IF FromDesktop THEN
  274.       ErrorMessage:= "[3][| Gerät nicht verfügbar. ][Abbruch]";
  275.     (*ErrorMessage:= "[3][| Device not available. ][Cancel]";*)
  276.       VOID(FormAlert(1,PTR(ErrorMessage)));
  277.       ApplExit;
  278.     ELSE
  279.       IF ScreenHandle > 0 THEN
  280.         ErrorMessage:= "Gerät nicht verfügbar. Taste... ";
  281.       (*ErrorMessage:= "Device not available. Hit any key...";*)
  282.         VEnterCur(ScreenHandle);
  283.         VCurHome(ScreenHandle);
  284.         VCurText(ScreenHandle,ErrorMessage);
  285.         Wait;
  286.         VExitCur(ScreenHandle);
  287.       END;
  288.     END;
  289.   END;
  290. END House;
  291.  
  292. (***************************************************************************)
  293.  
  294. BEGIN
  295.   House(Screen,RC);
  296.   House(Screen,NDC);
  297.  
  298.   House(Plotter,RC);
  299.   House(Plotter,NDC);
  300.  
  301.   House(Printer,RC);
  302.   House(Printer,NDC);
  303.  
  304.   House(Printer + 1,RC); (* second printer *)
  305.   House(Printer + 1,NDC);
  306.  
  307.   MetaName:= "HOUSERC.GEM";
  308.   House(Metafile,RC);
  309.   MetaName:= "HOUSENDC.GEM";
  310.   House(Metafile,NDC);
  311.  
  312.   House(Camera,RC);
  313.   House(Camera,NDC);
  314.  
  315.   House(Memory,RC);
  316.   House(Memory,NDC);
  317.  
  318.   House(Image,RC);
  319.   House(Image,NDC);
  320. END VDITest.
  321.